﻿using System;
using Sustainalytics.Entities.ESGRatings;

namespace Sustainalytics.ESGRatings.Service.Models
{
    public class WeightMatrixDto
    {
        public Guid Id { get; set; }
        public Guid? AccountId {get; set;}
        public string Name { get; set; }
        public bool IsSelectedInActiveProfile { get; set; }
        public DateTime? MarkedForDeletionOn { get; set; }

        private WeightMatrixDto() { } // prohibit public instantiation

        public static WeightMatrixDto CreateComplete(WeightMatrix weightMatrix, Guid? activeESGProfileMatrixId)
        {
            if (weightMatrix == null)
            {
                throw new ArgumentNullException("weightMatrix", "Weight matrix cannot be null.");
            }

            return new WeightMatrixDto { 
                Id = weightMatrix.Id, 
                AccountId = weightMatrix.AccountId,
                Name = weightMatrix.Name,
                IsSelectedInActiveProfile = (weightMatrix.Id == activeESGProfileMatrixId),
                MarkedForDeletionOn = weightMatrix.MarkedForDeletionOn
            };
        }
    }
}
